﻿create database StudentManagementDatabase
go

use StudentManagementDatabase
go

create table Manager
(
	id int identity (1,1) primary key,
	username varchar (20) unique,
	password varchar (40),
)

insert into Manager (username, password)
values ('TramNN', 'hieubihap')
insert into Manager (username, password)
values ('HieuTD', 'hieubidien')

create table Student
(
	id int identity (1,1) primary key,
	name nvarchar (50),
	age int,
	sex int,
	hometown nvarchar (25),
)

insert into Student (name, age, sex, hometown)
values (N'Nguyễn Ngọc Minh', 20, 1, N'Bắc Giang')
insert into Student (name, age, sex, hometown)
values (N'Lưu Đức Đông', 21, 1, N'Quảng Nam')
insert into Student (name, age, sex, hometown)
values (N'Nguyễn Xuân Tài', 20, 0, N'Nghệ An')


CREATE TABLE Category(
	id int IDENTITY(1,1) PRIMARY KEY,
	name nvarchar(80),
	slug varchar(80),
	parentID int FOREIGN KEY REFERENCES Category(id)
);

CREATE TABLE News(
	id int IDENTITY(1,1) PRIMARY KEY,
	title nvarchar(255),
	slug nvarchar(255),
	dateline int,
	content ntext,
	tags nvarchar(255),
	cid int FOREIGN KEY REFERENCES Category(id),
	mid int FOREIGN KEY REFERENCES Manager(id)
);